<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		
	</body>
</html>
<script type="text/javascript">
	var arr = [11,22,33,44,55,66];
	var reducer = [];
	
	var obj = {
		name:"zjj",
		age:"18"
	}
	// 传入了obj
	// var arr2 = arr.reduce(function(sum,val,idx,nowarr){
	// 	console.log(sum,val);
	// 	reducer.push(sum.name + ": " +val+ " 索引为：" + idx);
	// 	return sum   //每次回调都会记住上一次回调返回的值
	// },obj)
	// console.log(arr,reducer,arr2)
	//未传入obj
	var arr3 = arr.reduce(function(sum,val,idx,nowarr){
		console.log(sum,val)
		return sum +4;
	})
	// 
	// console.log(arr,arr2)	
	
	//去重
	// var arr4 = [1,1,'true','true',true,true,15,15,false,false,undefined,undefined,null,null,NaN, NaN,'NaN','NaN',0, 0, 'a', 'a',{},{}];
	// var arr5 = arr4.sort().reduce(function(sum,val){
	// 	if(sum.length === 0 || sum[sum.length - 1] !== val){
	// 		sum.push(val)
	// 	}
	// 	return sum
	// },[])
	// console.log(arr4)
	// console.log(arr5)
</script>